//
//  ScreeningTunerConditionView.m
//  TheRoadAD
//
//  Created by 宁宁 on 16/8/11.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "ScreeningTunerConditionView.h"

#define buttonWidth 85

@implementation ScreeningTunerConditionView 
{
    /**外观控ScrollView*/
    UIScrollView *_wgkScrollView;
    /**性能控ScrollView*/
    UIScrollView *_xnkScrollView;
    /**风格ScrollView*/
    UIScrollView *_fgScrollView;
    
    /**性能BtnArray*/
    NSMutableArray *_wgkButtonArray;
    /**外观BtnArray*/
    NSMutableArray *_xnkButtonArray;
    /**风格BtnArray*/
    NSMutableArray *_fgButtonArray;
}


- (void)setView{
    UILabel *waiguankong = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, 50, 20)];
    waiguankong.font = [UIFont fontWithName:AppFont size:14];
    waiguankong.text = @"外观控:";
    [self addSubview:waiguankong];
    
    UILabel *xingnengkong = [[UILabel alloc] initWithFrame:CGRectMake(15, 42, 50, 20)];
    xingnengkong.font = [UIFont fontWithName:AppFont size:14];
    xingnengkong.text = @"性能控:";
    [self addSubview:xingnengkong];
    
    UILabel *fengge = [[UILabel alloc] initWithFrame:CGRectMake(15, 74, 50, 20)];
    fengge.font = [UIFont fontWithName:AppFont size:14];
    fengge.text = @"风格";
    [self addSubview:fengge];
    
    _wgkScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(waiguankong.frame.size.width + waiguankong.frame.origin.x + 5, 0, Screen_Width - (waiguankong.frame.size.width + waiguankong.frame.origin.x + 5), 30)];
    //实际尺寸
    _wgkScrollView.contentSize = CGSizeMake(_wgkArray.count * (buttonWidth + 2), 30);
    _wgkScrollView.delegate = self;
    _wgkScrollView.showsHorizontalScrollIndicator = NO;
    [self addSubview:_wgkScrollView];
    
    _xnkScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(xingnengkong.frame.size.width + xingnengkong.frame.origin.x + 5, 32, Screen_Width - (xingnengkong.frame.size.width + xingnengkong.frame.origin.x + 5), 30)];
    //实际尺寸
    _xnkScrollView.contentSize = CGSizeMake(_xnkArray.count * (buttonWidth + 2), 30);
    _xnkScrollView.delegate = self;
    _xnkScrollView.showsHorizontalScrollIndicator = NO;
    [self addSubview:_xnkScrollView];
    
    _fgScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(fengge.frame.size.width + fengge.frame.origin.x + 5, 64, Screen_Width - (fengge.frame.size.width + fengge.frame.origin.x + 5), 30)];
    //实际尺寸
    _fgScrollView.contentSize = CGSizeMake(_fgArray.count * (buttonWidth + 2), 30);
    _fgScrollView.delegate = self;
    _fgScrollView.showsHorizontalScrollIndicator = NO;
    [self addSubview:_fgScrollView];
    
    
    _wgkButtonArray = [NSMutableArray array];
    for (int i = 0; i < _wgkArray.count; i++) {
        UIButton *condition = [UIButton buttonWithType:UIButtonTypeCustom];
        condition.frame = CGRectMake(i * (buttonWidth + 2), 10, buttonWidth, 20);
        [condition setTitle:_wgkArray[i] forState:UIControlStateNormal];
        condition.titleLabel.font = [UIFont fontWithName:AppFont size:15];
        [condition setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [condition addTarget:self action:@selector(waiguanClick:) forControlEvents:UIControlEventTouchUpInside];
        [_wgkScrollView addSubview:condition];
        
        [_wgkButtonArray addObject:condition];
        
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(condition.frame.origin.x + condition.frame.size.width, 12, 2, 14)];
        line.backgroundColor = [UIColor blackColor];
        [_wgkScrollView addSubview:line];
    }
    
    _xnkButtonArray = [NSMutableArray array];
    for (int i = 0; i < _xnkArray.count; i++) {
        UIButton *condition = [UIButton buttonWithType:UIButtonTypeCustom];
        condition.frame = CGRectMake(i * (buttonWidth + 2), 10, buttonWidth, 20);
        [condition setTitle:_xnkArray[i] forState:UIControlStateNormal];
        condition.titleLabel.font = [UIFont fontWithName:AppFont size:15];
        [condition setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [condition addTarget:self action:@selector(xingnengClick:) forControlEvents:UIControlEventTouchUpInside];
        [_xnkScrollView addSubview:condition];
        
        [_xnkButtonArray addObject:condition];
        
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(condition.frame.origin.x + condition.frame.size.width, 11, 2, 16)];
        line.backgroundColor = [UIColor blackColor];
        [_xnkScrollView addSubview:line];
    }
    
    _fgButtonArray = [NSMutableArray array];
    for (int i = 0; i < _fgArray.count; i++) {
        UIButton *condition = [UIButton buttonWithType:UIButtonTypeCustom];
        condition.frame = CGRectMake(i * (buttonWidth + 2), 10, buttonWidth, 20);
        [condition setTitle:_fgArray[i] forState:UIControlStateNormal];
        condition.titleLabel.font = [UIFont fontWithName:AppFont size:15];
        [condition setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [condition addTarget:self action:@selector(fenggeClick:) forControlEvents:UIControlEventTouchUpInside];
        [_fgScrollView addSubview:condition];
        
        [_fgButtonArray addObject:condition];
        
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(condition.frame.origin.x + condition.frame.size.width, 11, 2, 16)];
        line.backgroundColor = [UIColor blackColor];
        [_fgScrollView addSubview:line];
    }
}

- (void)waiguanClick:(UIButton *)sender{
    for (int i = 0; i < _wgkButtonArray.count; i++) {
        UIButton *button = _wgkButtonArray[i];
        if (button == sender) {
            [button setTitleColor:UIColorFromRGB(0x03dace) forState:UIControlStateNormal];
            _wgClick(_wgkArray[i]);
        }else [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
}


- (void)xingnengClick:(UIButton *)sender{
    for (int i = 0; i < _xnkButtonArray.count; i++) {
        UIButton *button = _xnkButtonArray[i];
        if (button == sender) {
            [button setTitleColor:UIColorFromRGB(0x03dace) forState:UIControlStateNormal];
            _xnClick(_xnkArray[i]);
        }else [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
}



- (void)fenggeClick:(UIButton *)sender{
    for (int i = 0; i < _fgArray.count; i++) {
        UIButton *button = _fgButtonArray[i];
        if (button == sender) {
            [button setTitleColor:UIColorFromRGB(0x03dace) forState:UIControlStateNormal];
            _fgClick(_fgArray[i]);
        }else [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
}

@end
